#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 4e5 + 5;

int n, k;
ll a[N], b[N], d[N];
using pll = pair<ll, ll>;
int solve() {
  rep(i, 1, n * 2) d[i] = b[i] - a[i];
  ll ans = 0;
  stack<pll> st;
  per(i, n * 2, n + 1) {
    if (d[i] == 0)
      continue;
    else
      st.push(pll(d[i], i));
  }
  per(i, n, 1) {
    if (d[i] == 0)
      continue;
    else if (d[i] > 0) {
      st.push(pll(d[i], i));
    } else {
      ll sum = d[i];
      ll j = i;
      while (sum < 0) {
        pll now = st.top();
        st.pop();
        sum += now.first;
        j = now.second;
        ans = max(ans, j - i);
      }
      if (sum > 0) st.push(pll(sum, j));
    }
  }
  return ans + 1;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    rep(i, 1, n) cin >> a[i];
    rep(i, 1, n) cin >> b[i];
    rep(i, 1, n) a[i + n] = a[i];
    rep(i, 1, n) b[i + n] = b[i];
    cout << solve() << endl;
  }
  return 0;
}